package com.example.rabbit.service.impl;

import com.example.common.dto.BaseReturnDto;
import com.example.rabbit.entity.RabbitDO;
import com.example.rabbit.mapper.RabbitMapper;
import com.example.rabbit.service.RabbitService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author tc
 * @since 2022-10-29
 */
@Service
public class RabbitServiceImpl extends ServiceImpl<RabbitMapper, RabbitDO> implements RabbitService {
    @Autowired
    RabbitMapper rabbitMapper;

    @Override
    public List<Map<String, Object>> getCandR(){
        return rabbitMapper.getCandR();
    }

    @Override
    public BaseReturnDto<RabbitDO> addRabbit(String varieties,String name,String sex,String saleTime,String cid,String color,Integer statu) {
        RabbitDO rabbitDO = new RabbitDO();
        rabbitDO.setVarieties(varieties);
        rabbitDO.setName(name);
        rabbitDO.setSex(sex);
        rabbitDO.setSaleTime(saleTime);
        rabbitDO.setCid(cid);
        rabbitDO.setColor(color);
        rabbitDO.setStatus(statu);
        int i =baseMapper.insert(rabbitDO);
        if (i>0){
            return BaseReturnDto.success().msg("添加成功");
        }else {
            return BaseReturnDto.error().msg("添加失败");
        }


    }
}
